﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.IDAL;
using Register.Model;
using Register.DALFactory;
using Register.Command;

namespace Register.BLL
{
    /// <summary>
    /// FileName: SchedulingInfoBLL.cs
    /// CLRVersion: 4.0.30319.269
    /// Author: WangKunLun
    /// Corporation: 
    /// Description: 
    /// DateTime: 2012/6/30 23:11:24
    /// </summary>
    public class SchedulingInfoBLL
    {
        private static String typeNameKey = "ISchedulingInfoDALKey";

        public static bool AddSchedulingInfo(Model.SchedulingInfo model)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);
            try
            {
                if (iSchedulingInfo.AddSchedulingInfo(model) > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        public static bool DeleteSchedulingInfo(string SchedulingInfoID)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);
            try
            {
                if (iSchedulingInfo.DeleteSchedulingInfo(SchedulingInfoID) > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        public static bool UpdateSchedulingInfo(Model.SchedulingInfo model)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);
            try
            {
                if (iSchedulingInfo.UpdateSchedulingInfo(model) > 0)
                {
                    return true;
                }
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        public static List<Model.SchedulingInfo> GetPagedSchedulingInfo(int size, int pageIndex, string where)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);

            try
            {
                return iSchedulingInfo.GetPagedSchedulingInfo(size, pageIndex, where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        public static List<Model.DoctorInfo> GetDoctorInfo(String where)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);

            try
            {
                return iSchedulingInfo.GetDoctorInfo(where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        public static Model.SchedulingInfo GetSchedulingInfo(string SchedulingInfoID)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);
            try
            {
                return iSchedulingInfo.GetSchedulingInfo(SchedulingInfoID);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        public static int GetSchedulingInfoCount(string where)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);

            try
            {
                return iSchedulingInfo.GetSchedulingInfoCount(where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #region 获取医生安排信息
        public static List<Model.SchedulingInfo> GetPagedScheduling(int size, int pageIndex, string where)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);
            try
            {
                return iSchedulingInfo.GetPagedScheduling(size, pageIndex, where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        public static int GetSchedulingInfoCount1(string where)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);

            try
            {
                return iSchedulingInfo.GetSchedulingInfoCount1(where);
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #endregion
        #region 确认操作
        public static bool UpdateScheduling(Model.SchedulingInfo model)
        {
            ISchedulingInfoDAL iSchedulingInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);
            try
            {
                if (iSchedulingInfo.UpdateScheduling(model) > 0)
                {
                    return true;
                }
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }

        #endregion
        #region 添加调整申请
        public static bool AddSchedulingAdjustmentInfo(Model.SchedulingAdjustmentInfo model)
        {
            ISchedulingInfoDAL iSchedulingAdjustmentInfo = DALFactory<ISchedulingInfoDAL>.Create(typeNameKey);
            try
            {
                if (iSchedulingAdjustmentInfo.AddSchedulingAdjustment(model) > 0)
                    return true;
                else
                    return false;
            }
            catch (Exception e)
            {
                LogRecordHelper.LogNote("ERROR", e.Message);
                throw e;
            }
        }
        #endregion
    }
}
